///*
// * ScheduledTaskRunnerTestCase.fx
// *
// * Created on May 5, 2010, 12:43:21 PM
// */
//
//package fxification.test;
//
//import junit.framework.TestCase;
//import fxification.async.TaskRunner;
//import junit.framework.Assert;
//import junit.textui.TestRunner;
//import java.lang.RuntimeException;
//
///**
// * @author vvivien
// */
//
//public class ScheduledTaskRunnerTestCase extends TestCase {
//    public function testTaskRunnerAction(): Void {
//        var sum = 0.0;
//        def taskRunner = TaskRunner.ScheduledTask{
//            action:function(){
//                sum = 1 + 2
//            }
//        }
//
//        Assert.assertNotNull("Action property not set", taskRunner.action);
//        taskRunner.action();
//        Assert.assertTrue("Action fn not invoked correctly", sum == 3);
//    }
//
//    public function testTaskRunnerPeriod():Void {
//        def taskRunner = TaskRunner.ScheduledTask {delay:100ms period:1000s}
//        Assert.assertEquals("Task delay value not set properly", 100ms, taskRunner.delay);
//        Assert.assertEquals("Task period value not set properly", 1000s, taskRunner.period);
//    }
//
//    public function testTaskRunnerStartStop(): Void {
//        var sum = 0.0;
//        def task = TaskRunner.ScheduledTask {
//            period:1s
//            action:function (){
//                sum = sum + 2;
//                println (sum);
//            }
//        }
//        task.start();
//
//        FX.deferAction(
//            function(){
//                java.lang.Thread.currentThread().sleep(800.00); // stall a bit
//                Assert.assertTrue("Task not starting after TaskRunner.start()", sum mod 2 == 0);
//                task.stop();
//            }
//        );
//    }
//
//    public function testTaskRunnerStartEvent():Void {
//        var sum = 0;
//        def task:TaskRunner.ScheduledTask = TaskRunner.ScheduledTask {
//            period:1s
//            action: function() {sum = sum + 2}
//            onStart:function() {
//                Assert.assertTrue("Task not starting after TaskRunner.start()", task.started);
//                Assert.assertTrue("Task not stopping after TaskRunner.stop()", not task.stopped);
//                task.stop();
//            }
//        }
//        task.start();
//    }
//
//
//    public function testTaskRunnerStopEvent():Void {
//        var sum = 0;
//        def task:TaskRunner.ScheduledTask = TaskRunner.ScheduledTask {
//            period:1s
//            action: function() {sum = sum + 2}
//            onStart:function() {
//                Assert.assertTrue("Task not starting after TaskRunner.start()", task.started);
//                Assert.assertTrue("Task not stopping after TaskRunner.stop()", not task.stopped);
//                task.stop();
//            }
//
//            onDone:function(){
//                Assert.assertTrue("Task stopped, but not marked stopped.", task.stopped);
//                Assert.assertTrue("Task stopped, but marked done.", task.done);
//                Assert.assertTrue("Task stopped, but marked succeeded.", not task.succeeded);
//                Assert.assertTrue("Task stopped, but marked succeeded.", not task.succeeded);
//            }
//        }
//        task.start();
//    }
//
//
//public function testTaskException (){
//       var fibbo = 0;
//        def task:TaskRunner.ScheduledTask = TaskRunner.ScheduledTask {
//            period:1s
//            action:function() {
//                for(i in [0..99])
//                    if(i >= 10){
//                        throw new RuntimeException("Number too high")
//                    }
//            }
//            onStart:function() {
//                Assert.assertTrue("Task not starting after TaskRunner.start()", task.started);
//                Assert.assertTrue("Task not stopping after TaskRunner.stop()", not task.stopped);
//                task.stop();
//            }
//
//            onDone:function(){
//                Assert.assertNotNull(task.causeOfFailure);
//                Assert.assertTrue("Task stopped, but not marked stopped.", task.stopped);
//                Assert.assertTrue("Task stopped, but marked done.", task.done);
//                Assert.assertTrue("Task stopped, but marked succeeded.", not task.succeeded);
//            }
//
//        }
//        task.start();
//    }
//
//}
//
//public function run() {
//    def test = TestRunner{};
//    test.run(test.getTest(ScheduledTaskRunnerTestCase.class.getName()));
//}
